//
//  LSZRequestResolutionDic.m
//  JK九酷云头条
//
//  Created by 九酷 on 2017/11/6.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LSZRequestResolutionDic.h"
#import "LSZRequestTotal.h"
#import <pthread.h>
@implementation LSZRequestResolutionDic
#pragma mark - 视频的数据解析
+(void)initWithVideoChooseRequestData :(HTTPVideo)block
{
     NSString * str = [NSString stringWithFormat:@"%@%@",URLTotal,@"/news/video_cate"];
    NSDictionary * dic = [[NSDictionary alloc]init];
    
    [LSZRequestTotal initWithPostRequest:str :dic :^(BOOL isOK, NSString * str, NSDictionary * dic) {
        if (isOK == YES) {
            NSString * status = [NSString stringWithFormat:@"%@",dic[@"status"]];
            NSString * msg = [NSString stringWithFormat:@"%@",dic[@"msg"]];
            if ([status isEqualToString:@"1"]) {
                dispatch_queue_t  queue= dispatch_queue_create("videoChoose", NULL);
                dispatch_async(queue, ^{
                    NSString * string  = [NSString stringWithFormat:@"%@",videoChoose];
                    [LSZCacheHandling initAddPathPraisePoetry:string NSDictionary:dic];
                });
                 LSZVideoManager * mg = [[LSZVideoManager alloc]initWithVideoManager:dic];
                block(YES,OK,mg);
            }else{
                block(NO,msg,nil);
            }
         }else{
            block(NO,str,nil);
        }
     }];
}
#pragma mark - 视频的分类的选择
+(void)initWithVideoDetailChooseRequestData:(NSString *)cid last_id:(NSString *)last_id first_id:(NSString *)first_id :(HTTPVideoSelection)block
{
    NSString * str = [NSString stringWithFormat:@"%@%@",URLTotal,@"/news/video_lists"];
    NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:cid,@"cid",first_id,@"first_id",last_id,@"last_id", nil];
    NSLog(@"传入的参数<<%@",dic);
    
    [LSZRequestTotal initWithPostRequest:str :dic :^(BOOL isOK, NSString * str, NSDictionary * dic) {
        if (isOK == YES) {
            NSArray * array = dic[@"data"];
//            NSLog(@"%zd>>>请求的个数",array.count);
            NSString * status = [NSString stringWithFormat:@"%@",dic[@"status"]];
            NSString * msg = [NSString stringWithFormat:@"%@",dic[@"msg"]];
            if ([status isEqualToString:@"1"]) {
                dispatch_queue_t  queue= dispatch_queue_create("videoDetail", NULL);
                dispatch_async(queue, ^{
                    NSString * string  = [NSString stringWithFormat:@"%@_%@",videoChoose,cid];
                    [LSZCacheHandling initAddPathPraisePoetry:string NSDictionary:dic];
                });
                 LSZDetailsVideoSelectionManager * mg = [[LSZDetailsVideoSelectionManager alloc]initWithDetailsVideoSelectionManager:dic];
                block(YES,OK,mg);
            }else{
                block(NO,msg,nil);
            }
        }else{
            block(NO,str,nil);
        }
    }];
}
#pragma mark - 热文
+(void)initWithHotRequestData:(HTTPHot)block
{
    NSDictionary * dic = [[NSDictionary alloc]init];
    NSString * str = [NSString stringWithFormat:@"%@/news/push_lists",URLTotal];
    [LSZRequestTotal initWithPostRequest:str :dic :^(BOOL isOK, NSString * str, NSDictionary * dic) {
        if (isOK == YES) {
            NSArray * array = dic[@"data"];
//            NSLog(@"%zd>>>请求的个数",array.count);
            NSString * status = [NSString stringWithFormat:@"%@",dic[@"status"]];
            NSString * msg = [NSString stringWithFormat:@"%@",dic[@"msg"]];
            if ([status isEqualToString:@"1"]) {
                dispatch_queue_t  queue= dispatch_queue_create("renwen", NULL);
                dispatch_async(queue, ^{
                    NSString * string  = [NSString stringWithFormat:@"%@ ",rewen];
                    [LSZCacheHandling initAddPathPraisePoetry:string NSDictionary:dic];
                });
                LSZHotManager * mg = [[LSZHotManager alloc]initWithHotManager:dic];
                block(YES,OK,mg);
            }else{
                block(NO,msg,nil);
            }
        }else{
            block(NO,str,nil);
        }
    }];
}
//#pragma mark - 头条首页的内容
//+(void)initWithConut:(HTTPHot)block
//{
//    NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:@"255",@"cid",@"0",@"last_id",@"0",@"first_id", nil];
//    NSString *str = [NSString stringWithFormat:@"http://toutiao.api.inping.com/news/lists"];
//    [LSZRequestTotal initWithPostRequest:str :dic :^(BOOL isOK, NSString * str, NSDictionary * dic) {
//        if (isOK == YES) {
//            NSArray * array = dic[@"data"];
//            NSLog(@"%zd>>>请求的个数",array.count);
//
//        }else{
//            block(NO,str,nil);
//        }
//    }];
//}
@end
